<template>
  <el-dialog :visible.sync="dialog1" title="提现驳回" width="500px" >
    <div>
      <el-form ref="form" :rules="rules" :model="form" label-width="100px">
        <el-form-item label="驳回原因" prop="remark" >
          <el-input v-model="form.remark" type="textarea"/>
        </el-form-item>
      </el-form>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button size="small" @click="cancel">取消</el-button>
      <el-button :loading="loading" size="small" type="primary" @click="doSubmit">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { mapGetters } from 'vuex'
import { rebutReceipt } from '@/api/mall/cashManage'
export default {
  components: {},
  props: {
  },
  data() {
    return {
      dialog1: false,
      loading: false,
      url: '',
      form: {
        remark: '',
        receipt_no: []
      },
      rules: {
        remark: [
          { required: true, message: '请输入驳回原因', trigger: 'blur' }
        ]
      }
    }
  },
  computed: {
    ...mapGetters([
      'ossUrl'
    ])
  },
  methods: {
    cancel() {
      this.resetForm()
      this.dialog1 = false
    },
    doSubmit() {
      if (!this.form.remark) {
        this.$notify({
          title: '驳回原因不能为空',
          type: 'error',
          duration: 2500
        })
        return
      }
      rebutReceipt(this.form).then(res => {
        if (res) {
          this.$notify({
            title: '驳回成功',
            type: 'success',
            duration: 2500
          })
          this.dialog1 = false
          this.resetForm()
          this.$parent.init()
        } else {
          this.$notify({
            title: '驳回失败',
            type: 'error',
            duration: 2500
          })
          this.dialog1 = false
          this.resetForm()
        }
      })
    },
    resetForm() {
      this.form = {
        remark: ''
      }
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
</style>
